`include "common.svh"
import "DPI-C" function int iram_read(
  longint pc,
  int offset
);
module iram (
    input clk,
    input rst,
    // IRAM Req
    output req_ready,
    input req_valid,
    input IRAM_Req req,
    // IRAM Rsp
    output IRAM_Rsp rsp
);
  assign req_ready = 1'b1;
  always_ff @(posedge clk) begin
    integer i;
    if (rst) begin
      for (i = 0; i < `IRAM_WIDTH; i = i + 1) begin
        rsp.inst[i] <= 'b0;
      end
    end else if (req_ready & req_valid) begin
      for (i = 0; i < `IRAM_WIDTH; i = i + 1) begin
        rsp.inst[i] <= iram_read(req.pc, i);
      end
    end
  end

endmodule
